package utils

import "time"

type CountTime struct {
	StartTime time.Time //下载开始时间
	EndTime   time.Time //下载结束时间
}

func New() CountTime {
	countTime := CountTime{}
	countTime.StartTime = time.Now()
	return countTime
}

func (countTime *CountTime) Start() {
	countTime.StartTime = time.Now()
}

func (countTime *CountTime) End() {
	countTime.EndTime = time.Now()
}

func (countTime *CountTime) GetExeTime() time.Duration {
	return countTime.EndTime.Sub(countTime.StartTime)
}

func (countTime *CountTime) EndAndGetExeTime() time.Duration {
	countTime.EndTime = time.Now()
	return countTime.EndTime.Sub(countTime.StartTime)
}
